//获取到用户所有的收藏信息
getAllAttention();
function getAllAttention() {
    var customerId = $(".customerid").val();
    $.ajax({
        type:"GET",
        url:"/fresh/attention/getAll/"+customerId,
        datatype:"json",
        success:function (result) {
            console.log(result);
            if (result.status==1){
                console.log("查询成功");
                $(".product-list").html("");
                var str="";
                /*var voList = result.date;*/

                $.each(result.data,function (index,productList) {
                    var productName = productList.product.productName;
                    var productId = productList.product.productId;
                    var productPrice = productList.product.productPrice;
                    var attentionId = productList.attention.attentionId;
                    var productImages = productList.attention.productImages;
                    var attentionTime = productList.attention.attentionTime;
                    console.log("productName:"+productName);
                    console.log("productPrice:"+productPrice);
                    console.log("productName:"+productName);
                    console.log("productImages:"+productImages);
                    console.log("attentionId:"+attentionId);

                    var ele="<li>\n" +
                        "                        <div class=\"attention-all\">\n" +
                        "                            <input type=\"hidden\" class=\"attentionId\" name=\"attentionId\"value="+attentionId+">\n" +
                        "                            <div class=\"pro-mess\">\n" +
                        "                                <img src='/fresh/images/"+productImages+"' class=\"img-img\">\n" +
                        "                            </div>\n" +
                        "                            <div class=\"pro-name\">\n" +
                        "                                <a href=\"\" class=\"pro-name-a\">\n" +
                        "                                    <span class=\"pro-name-span\">"+productName+"</span>\n" +
                        "                                </a>\n" +
                        "                            </div>\n" +
                        "                            <div class=\"pro-price\">\n" +
                        "                                <span class=\"pro-price-b\">￥</span>\n" +
                        "                                <span class=\"pro-desc-span\">"+productPrice+"</span>\n" +
                        "                                <a href=\"javascript:deleteAttention("+attentionId+");\" class=\"buutton-quxiao\">取消关注</a>\n" +
                        "                            </div>\n" +
                        "                        </div>\n" +
                        "\n" +
                        "\n" +
                        "                    </li>"
                    str +=ele;

                })
                $(".product-list").html(str);
            }else {
                console.log("查询失败");
            }
        }


    })
}


//删除某一个商品
function deleteAttention(attentionId) {
    console.log("attention:"+attentionId);
    $.ajax({
        type: "GET",
        url: "/fresh/attention/delete/"+attentionId,
        datatype: "json",
        success:function (result) {
            console.log("result:"+result);
            if (result.status==1){
                console.log("删除成功");
                getAllAttention();
            }else {
                console.log("删除失败");
            }
        }
    })
}